package acwing.双指针;

import java.util.Scanner;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/11/7
 */
public class 最长连续不重复子序列 {

    static int N = 100010;
    static int[] a = new int[N];
    static int[] s = new int[N];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int res = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt(); // 1 2 2 3 5
        }
        for (int i = 0, j = 0 ; i < n; i++) {
            s[a[i]]++;  //  s[a[0]] = 1  s[a[1]] = 1 s[a[2]] = 2;
            while (s[a[i]] > 1) { // 重复的数就是a[i]
                s[a[j]]--; // 1
                j++;
            }

            res = Math.max(res,i - j + 1);
        }
        System.out.println(res);
    }
}
